# 获取当前用户目录下的所有conda环境路径
# (English: Retrieve all conda environment paths under the current user's directory)
$envs = (conda env list --json | ConvertFrom-Json).envs

# 定义一个函数来获取文件夹大小，并以GB为单位显示
# (English: Define a function to get the size of the folder in GB)
function Get-FolderSizeInGB {
    param (
        [string]$path
    )
    
    # 计算文件夹大小，单位为字节
    # (English: Calculate the size of the folder in bytes)
    $sizeInBytes = (Get-ChildItem -Path $path -Recurse | Measure-Object -Property Length -Sum).Sum
    
    # 转换大小为GB并保留两位小数
    # (English: Convert the size to GB and keep two decimal places)
    return [math]::Round(($sizeInBytes / 1GB), 2)
}

# 遍历每个环境并获取其大小
# (English: Iterate through each environment and get its size)
foreach ($env in $envs) {
    $folderSizeGB = Get-FolderSizeInGB -path $env
    Write-Host "Environment: $env"
    Write-Host "Size: $folderSizeGB GB"
}




